package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.LendReturn;
import com.atguigu.srb.core.service.LendReturnService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 还款记录表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/admin/core/lendReturn")
@Api(tags = "回款管理")
public class AdminLendReturnController {
    @Resource
    LendReturnService lendReturnService;
    @ApiOperation("admin中还款计划的查询和展示")
    @GetMapping("/returnPlan/{lendId}")
    public R getReturnPlan(@PathVariable("lendId")Long lendId){
        //这个查询不区分还款和未还款的,按照升序的来展示  /admin/core/lendReturn
        List<LendReturn> list = lendReturnService.list(Wrappers.lambdaQuery(LendReturn.class)
                        .eq(LendReturn::getLendId,lendId)
                .orderByAsc(LendReturn::getCurrentPeriod));
        return R.ok().data("items",list);
    }

}

